<!DOCTYPE html>
<html lang="en">
<head>
    <!--
    @Author 硕鼠
    @Date 2020/4/6 10:24
    @Version 1.0
    @Description 函数传参
  -->
    <meta charset="UTF-8">
    <title>函数传参</title>
    <script>
        function setColor(color){
            var oDiv = document.getElementById("div1");
            oDiv.style.background = color;
        }
    </script>
</head>
<body>
    <input type="button" value="变绿" onclick="setColor('green')">
    <input type="button" value="变黄" onclick="setColor('yellow')">
    <input type="button" value="变黑" onclick="setColor('blue')">
</body>
<div id = "div1">
    为了你的信息安全
</div>
</html>